@include('admin.layout.css')
@include('admin.layout.js')




<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">




    <div class="layui-form-item">
        <label for="type" class="layui-form-label">
            分类
        </label>
        <div class="layui-input-inline">
            <select id="category_id" name="category_id" >
                <option value="">请选择</option>
                @foreach($categorys as $value)
                    <option value="{{$value['category_id']}}">{{$value['category_name']}}</option>
                @endforeach
            </select>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label"> 商品状态</label>
        <div class="layui-input-block">
            <input type="radio" name="show" value="0" title="下架" >
            <input type="radio" name="show" value="1" title="上架" >
        </div>
    </div>

{{--    <div class="layui-form-item">--}}
{{--        <label class="layui-form-label"> 专卖店特供</label>--}}
{{--        <div class="layui-input-block">--}}
{{--            <input type="radio" name="is_zhuanmai" value="0" title="否" >--}}
{{--            <input type="radio" name="is_zhuanmai" value="1" title="是" >--}}
{{--        </div>--}}
{{--    </div>--}}

    <input type="hidden" name="is_zhuanmai" value="0">






    <div class="layui-form-item">
        <label class="layui-form-label"> 商品图</label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" id="test1">上传图片</button>
            <input type="hidden" name="project_image_project_view_url" id="img_url">
            <div class="layui-upload-list" >
                <img class="layui-upload-img"  id="img_url_show" width="92px" height="92px">
                <p id="demoText"></p>
            </div>
        </div>
    </div>







    <div class="layui-form-item">
        <label class="layui-form-label"> 商品名称</label>
        <div class="layui-input-block">
            <input type="text"  name="project_name"  placeholder="请输入 商品名称" autocomplete="off" class="layui-input" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"> 商品价格</label>
        <div class="layui-input-block">
            <input type="text"  name="project_price"  placeholder="请输入 商品价格" autocomplete="off" class="layui-input" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label"> 商品原价</label>
        <div class="layui-input-block">
            <input type="text"  name="origin_price"  placeholder="请输入 商品原价" autocomplete="off" class="layui-input" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">上级返佣</label>
        <div class="layui-input-inline">
            <input type="text"  name="spread_rate_price"  placeholder="请输入上级返佣" autocomplete="off" class="layui-input" >
        </div>

        <label class="layui-form-label">自购返佣</label>
        <div class="layui-input-inline">
            <input type="text"  name="me_rate_price"  placeholder="请输入自购返佣" autocomplete="off" class="layui-input" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"> 供应商ID</label>
        <div class="layui-input-inline">
            <input type="text"  name="shop_id"   placeholder="请输入合供应商ID" autocomplete="off" class="layui-input" >
        </div>

        <label class="layui-form-label">供应商分成</label>
        <div class="layui-input-inline">
            <input type="text"  name="shop_rate_price"   placeholder="请输入供应商分成" autocomplete="off" class="layui-input" >
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label"> 商品库存</label>
        <div class="layui-input-block">
            <input type="text"  name="stock" value="0"  placeholder="请输入 商品 商品库存" autocomplete="off" class="layui-input" >
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">最大购买次数</label>
        <div class="layui-input-block">
            <input type="text"  name="buy_max_num"  placeholder="请输入最大购买次数" autocomplete="off" class="layui-input" >
        </div>
    </div>



    <div class="layui-form-item">
{{--        <label class="layui-form-label"> 商品销量</label>--}}
{{--        <div class="layui-input-inline">--}}
{{--            <input type="text"  name="xiaoliang" value="0"  placeholder="请输入 商品销量" autocomplete="off" class="layui-input" >--}}
{{--        </div>--}}

        <label class="layui-form-label"> 商品阅读</label>
        <div class="layui-input-inline">
            <input type="text"  name="show_nums" value="0"  placeholder="请输入 商品阅读" autocomplete="off" class="layui-input" >
        </div>
    </div>






{{--    <div class="layui-form-item">--}}
{{--        <label class="layui-form-label">一级收益</label>--}}
{{--        <div class="layui-input-inline">--}}
{{--            <input type="text"  name="one_price"  placeholder="请输入一级收益" autocomplete="off" class="layui-input" >--}}
{{--        </div>--}}

{{--        <label class="layui-form-label">二级收益</label>--}}
{{--        <div class="layui-input-inline">--}}
{{--            <input type="text"  name="two_price"  placeholder="请输入二级收益" autocomplete="off" class="layui-input" >--}}
{{--        </div>--}}
{{--    </div>--}}






















    <div class="layui-form-item">
        <label class="layui-form-label"> 商品详情</label>
        <div class="layui-input-block">
            <textarea name="content1"  id="content1"></textarea>
        </div>
    </div>


{{--        <div class="layui-form-item">--}}
{{--            <label class="layui-form-label">地图图片</label>--}}
{{--            <div class="layui-input-block">--}}
{{--                <button type="button" class="layui-btn" id="test2">上传图片</button>--}}
{{--                <input type="hidden" name="ditu" id="img_url1" >--}}
{{--                <div class="layui-upload-list" >--}}
{{--                    <img class="layui-upload-img"  id="img_url_show1" width="92px" height="92px" >--}}
{{--                    <p id="demoText"></p>--}}
{{--                </div>--}}
{{--            </div>--}}
{{--        </div>--}}





    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="submit" id="submit" value="确认">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="取消">
    </div>

</div>

<script src="/static/admin_templete/ueditor/ueditor.config.js"></script>
<script src="/static/admin_templete/ueditor/ueditor.all.min.js"></script>


<script>



    var ue1 = UE.getEditor('content1',{
        initialFrameWidth:'450'  //初始化编辑器宽度,默认1000
        ,initialFrameHeight:'360'  //初始化编辑器高度,默认320
    });


    UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
    UE.Editor.prototype.getActionUrl = function(action) {
        if (action == 'uploadimage') {
            return "{{route('admin.local1')}}";
        } else {
            return this._bkGetActionUrl.call(this, action);
        }
    }



</script>

<script>


</script>

<script>



    UI.upload('#test1',function (res) {
        if (res.code !== 200) {
            Utils.errorToast(res.msg);
        }else{
            Utils.successToast('上传成功');
            $('#img_url_show').attr('src',res['data']['src']);
            $('#img_url').val(res['data']['src']);
        }
    });

    UI.upload('#test2',function (res) {
        if (res.code !== 200) {
            Utils.errorToast(res.msg);
        }else{
            Utils.successToast('上传成功');
            $('#img_url_show1').attr('src',res['data']['src']);
            $('#img_url1').val(res['data']['src']);
        }
    });

    UI.upload('#test3',function (res) {
        if (res.code !== 200) {
            Utils.errorToast(res.msg);
        }else{
            Utils.successToast('上传成功');
            $('#img_url_show3').attr('src',res['data']['src']);
            $('#img_url3').val(res['data']['src']);
        }
    });

    layui.use(['laydate','form'], function() {
        let form = layui.form;
        form.on('submit(submit)', function(data){
            data.field['content_value'] = ue1.getContent();
            Api.add("{{route('admin.xiangmu.add_project')}}",data.field,function(res){
                if (res.code !== 200){
                    Utils.errorToast(res.msg);
                    return;
                }
            });
        });


    });
</script>
